home *** CD-ROM | disk | FTP | other *** search
/ AOL File Library: 2,801 to 2,900 / aol-file-protocol-4400-2801-to-2900.zip / AOLDLs / C++ Files Library / C++ Spline Class V 1.02 / C++ Spline Class 1.02.sea / Spline Class / 2DSpline.h < prev    next >
Text File  |  1993-09-30  |  5KB  |  112 lines

  1. /************************************************************************************************/
  2. /*                                                         Chris Marshall                                                    */
  3. /*                                                                                                                                */
  4. /*                                                Nikon Electronic Imaging Dept                                            */
  5. /*                                                    1300 Walt Whitman Road                                                */
  6. /*                                                      Melville, NY 11747                                                    */
  7. /*                                                         (516) 547-4200                                                    */
  8. /*                                                                                                                                */
  9. /************************************************************************************************/
  10. /*        File Name:            2DSpline.h                                                                                    */
  11. /*        Description:        Declaration file for a 2-dimensional spline curve                                */
  12. /*        Primary Author:    Chris Marshall - based on an algorithm modified by Tom Knoll                */
  13. /*        Version:                1.0                                                                                            */
  14. /*        Project:                Library file                                                                                */
  15. /*        Compiler(s):        Symantec C++ 6.0                                                                            */
  16. /************************************************************************************************/
  17. /*                                                     MODIFICATION HISTORY                                                */
  18. /************************************************************************************************/
  19. /*    Date            Author                Description                                                                        */
  20. /*                                                                                                                                */
  21. /************************************************************************************************/
  22.  
  23. #pragma once                // This include file should only be used once
  24. #include    <FixMath.h>
  25.  
  26. /************************************************************************************************/
  27. /*                                                     CLASS DEFINITION                                                        */
  28. /************************************************************************************************/
  29.  
  30. class Spline
  31.     {
  32.     private:
  33.         long double    **fSlopeArray;
  34.         long double    **fPAl1;
  35.         long double    **fPAl2;
  36.         long double    **fPAl3;
  37.         
  38.         void    Initialize ( void );
  39.     
  40.     protected:
  41.         short    fNumPoints;
  42.         short    fSelectedPoint;
  43.         long    **fXArray;
  44.         long    **fYArray;
  45.         long    fHitRadius;
  46.         short    fAlloc;
  47.         
  48.         virtual void    CreateCoefficients ( void );
  49.  
  50.     public:
  51.         Spline ( long x0, long y0, long x1, long x1,
  52.                     long hitRadius );
  53.         Spline ( void ) { this->Initialize ( ); };
  54.         virtual ~Spline ( void );
  55.         
  56.         virtual short            AddSplinePoint ( long xValue, long yValue );
  57.         Boolean        PointIsOnLine ( long & xValue, long & yValue );
  58.         short            IsASplinePoint ( long & xValue, long & yValue, Boolean xOnly );
  59.         short            IsASplinePoint ( long & xValue, long & yValue )
  60.                 { return this->IsASplinePoint ( xValue, yValue, false ); };
  61.         short            IsASplinePoint ( long & xValue )
  62.                 { long temp; return this->IsASplinePoint ( xValue, temp, false ); };
  63.         short            PointIsBetween ( long xValue, short & above, short & below );
  64.         short            GetSplinePoint ( short index, long & xValue, long & yValue );
  65.         short            GetSplinePoint ( long & xValue, long & yValue )
  66.                 { this->GetSplinePoint ( fSelectedPoint, xValue, yValue ); return fSelectedPoint; };
  67.         virtual void            DeleteSplinePoint ( short index );
  68.         void             DeleteSplinePoint ( void ) { this->DeleteSplinePoint ( fSelectedPoint ); };
  69.         void            ChangeSplinePoint ( short & index, long xValue, long yValue );
  70.         short            ChangeSplinePoint ( long xValue, long yValue )
  71.                 { this->ChangeSplinePoint ( fSelectedPoint, xValue, yValue ); return fSelectedPoint; };
  72.         short            GetNumberOfSplinePoints ( void ) { return fNumPoints; };
  73.         virtual long            GetYValue ( long xValue );
  74.         virtual long double    GetRealYValue ( long double xValue );
  75.         virtual Fixed            GetFixYValue ( Fixed xValue )
  76.                 { return X2Fix ( this->GetRealYValue ( Fix2X ( xValue ) ) ); };
  77.         
  78.         void            SetHitRadius ( long hitRadius ) { fHitRadius = hitRadius; };
  79.         long            GetHitRadius ( long hitRadius ) { return fHitRadius; };
  80.         void            SelectPoint ( short index ) { fSelectedPoint = index; };
  81.         short            GetSelectedPoint ( void ) { return fSelectedPoint; };
  82.     };
  83.  
  84. #define    kInc    16    // The size of the blocks for allocating the working buffers
  85.  
  86. class FixedSpline : public Spline
  87.     {
  88.     private:
  89.         Fixed    **fFixedArray;
  90.         Fixed    **fPAf1;
  91.         Fixed    **fPAf2;
  92.         Fixed    **fPAf3;
  93.         
  94.         void    CreateCoefficients ( void );
  95.         void    Initialize ( void );
  96.     
  97.     public:
  98.         FixedSpline ( long x0, long y0, long x1, long x1, long hitRadius );
  99.         FixedSpline ( void ) { this->Initialize ( ); };
  100.         virtual ~FixedSpline ( void );
  101.         
  102.         short            AddSplinePoint ( long xValue, long yValue );
  103.         void            DeleteSplinePoint ( short index );
  104.         Fixed            GetFixYValue ( Fixed xValue );
  105.         long            GetYValue ( long xValue )
  106.                             { return Fix2Long ( this->GetFixYValue ( xValue << 16 ) ); };
  107.         long double    GetRealYValue ( long double xValue )
  108.                             { return Fix2X ( this->GetFixYValue ( X2Fix ( xValue ) ) ); };
  109.     };
  110.  
  111. /************************************************************************************************/
  112.